import requests
import urllib
import re

print("请输入学号:")
userId = input()
print("请输入密码:")
password = input()

#userId = "在这里输入学号"
#password = "在这里输入校园网密码"

url_getService = "http://172.30.0.11:80/eportal/userV2.do?method=getServices"
data_getService = {"username": userId, "search": ''}
getService = requests.post(url_getService,data_getService).text
service = urllib.parse.quote(getService.replace("校园网","").replace("@","").encode('UTF-8'))
url_wlanUserip = "http://172.30.0.11"
wlanUserip = requests.get(url_wlanUserip).text.replace("<script>top.self.location.href='http://172.30.0.11/eportal/index.jsp?","").replace("'</script>","")             
url_startConnect = "http://172.30.0.11:80/eportal/InterFace.do?method=login"
data_startConnect = {"userId": userId, "password": password, "service": service, "queryString":wlanUserip,"operatorPwd": '', "operatorUserId": '', "validcode": '', "passwordEncrypt": "false"}
startConnect = requests.post(url_startConnect,data_startConnect)
#print(service)
#print(wlanUserip)

print(startConnect.text)
